<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>[|.siteName|]</title>
    [|if .zTree|]
    <link rel="stylesheet" href="/static/zTree3/css/demo.css?t=5" type="text/css">
    <link rel="stylesheet" href="/static/zTree3/css/zTreeStyle/zTreeStyle.css" type="text/css"> [|end|]
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/main.css">
    <script src="/static/layui/layui.js?s=36"></script>
    <script src="/static/js/main.js?s=2124"></script>
    <script src="/static/js/echarts.js"></script>
</head>
<form>
    <div class="layui-input-inline">
        <div class="layui-inline">
            &nbsp&nbsp&nbsp&nbsp
            <div class="layui-inline"><label class="layui-form-label">用户推广号:</label></div>
            <div class="layui-input-inline" style="width:150px">
                <input type="text" name="userID" id="userID" lay-verify="required|number" autocomplete="off" class="layui-input" value="">
            </div>
        </div>


        <div class="layui-inline"><label class="layui-form-label">时间范围:</label></div>

        <div class="layui-input-inline" style="width:180px;">
            <input type="text" name="date1" id="date1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" value="">
        </div>
        <label>-</label>
        <div class="layui-input-inline" style="width:180px;">
            <input type="text" name="date2" id="date2" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input" value="">
        </div>

        <div class="layui-inline"><label class="layui-form-label">充值类型:</label></div>
        <select name="RechargeType" id="RechargeType" size="1" style="width: 100px;height: 37px" lay-verify="">
                <option value="0" selected="0">不限</option>
                <option value="1" >IOS</option>
                <option value="2">安卓</option>
                <option value="3">PC</option>
        </select>
        <div class="layui-inline"><label class="layui-form-label">用户类型:</label></div>
        <select name="userType" id="userType" size="1" style="width: 100px;height: 37px" lay-verify="">
                   <option value="-1" selected="0">不限</option>
                   <option value="0" >普通账号</option>
                   <option value="1">商人账号</option>
        </select>

        <div class="layui-inline">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="queryBtn">开始查询</button>
        </div>
    </div>

    <br />
    <hr class="layui-bg-gray">
    <div>
        <p>
            <label id="" style="color:rgb(0, 0, 0);">合计充值:</label>
            <label id="totalamount" style="color:red;">0元</label>
            <label id="" style="color:rgb(0, 0, 0);">,合计充值人数:</label>
            <label id="peopleCount" style="color:red;">0人</label>


        </p>
    </div>


    <table class="layui-table" lay-data="{width: 'full-10', height: 'full-105', url:'', page:true, id:'idTest'}" lay-filter="dataTable" id="dataTable"> </table>
</form>
<script type="text/html" id="barDemo">

</script>

<script>
    var $;
    layui.use(['table', 'form', 'layedit', 'laydate', 'jquery', 'element'], function() {
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;
        $ = layui.jquery
        var element = layui.element;
        table = layui.table;

        //填写默认时间
        Date.prototype.Format = function(fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份 
                "d+": this.getDate(), //日 
                "h+": this.getHours(), //小时 
                "m+": this.getMinutes(), //分 
                "s+": this.getSeconds(), //秒 
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                "S": this.getMilliseconds() //毫秒 
            };
            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }

        var date = new Date();
        var time1 = Date.parse(new Date()) / 1000; //获取当前秒数()
        var time2 = time1 + (24 * 3600);

        var unixTimestamp = new Date(time1 * 1000).Format("yyyy-MM-dd");

        document.getElementById('date1').value = unixTimestamp

        var unixTimestamp = new Date(time2 * 1000).Format("yyyy-MM-dd");

        document.getElementById('date2').value = unixTimestamp

        //日期
        laydate.render({
            elem: '#date1',
            //type: 'datetime',
            format: 'yyyy-MM-dd'
        });

        laydate.render({
            elem: '#date2',
            //type: 'datetime',
            format: 'yyyy-MM-dd'
        });

        //监听提交
        form.on('submit(queryBtn)', function(data) {
            btnClick("")
            return false;
        });

        btnClick("curDay")
        btnClick("")
    });






    function btnClick(curDay) {
        console.log("btnClick:" + curDay)
        var userID = document.getElementById("userID")
        var userType = document.getElementById("userType")
        var RechargeType = document.getElementById("RechargeType")
        var date1 = document.getElementById("date1")
        var date2 = document.getElementById("date2")

        table.render({
            elem: '#dataTable',
            //data: datas,
            where: {
                userID: userID.value,
                date1: date1.value,
                date2: date2.value,
                userType: userType.value,
                RechargeType: RechargeType.value

            },
            url: '/usersrechargelog/table',
            done: function(res, curr, count) {
                //alert(JSON.stringify(res))
                document.getElementById('totalamount').innerHTML = res.msg.totalMoney + "元"
                document.getElementById('peopleCount').innerHTML = res.msg.totalPeople + '人'

            },

            cols: [
                [ //标题栏
                    {
                        field: 'userid',
                        title: '推广号',
                        height: 300,
                        width: 300
                    }, {
                        field: 'nickname',
                        title: '昵称',
                        height: 300,
                        width: 200
                    }, {
                        field: 'amount',
                        title: '充值金额',
                        height: 300,
                        width: 150
                    }, {
                        field: 'glodamount',
                        title: '获得金币',
                        height: 300,
                        width: 200
                    }, {
                        field: 'time',
                        title: '充值时间',
                        height: 100,
                        width: 200
                    }, {
                        field: 'platform',
                        title: '充值平台',
                        height: 300,
                        width: 650
                    }
                ]
            ],
            skin: 'row', //表格风格
            even: true,
            page: true,
            limits: [30, 50, 100],
            limit: 100, //每页默认显示的数量
            width: 'full-10',
            rules: 'all',
            height: 'full-105'
        });
    }
</script>
</body>

</html>